#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy  as np
import pandas as pd
import talib as ta

eps = 1e-8

def signal(*args):
    # 收高差值 指标
    df = args[0]
    n = args[1]
    factor_name = args[2]

    high = df['high'].rolling(n, min_periods=1).mean()
    close = df['close']
    df[factor_name] = (close - high) / (high + eps)

    return df
